<?php
declare (strict_types=1);

namespace Plugin\Alarm\Model;

use Mine\MineModel;
use Plugin\File\Model\RdFileVoice;

class RdAlarmType extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_alarm_type';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'name', 'voice_id', 'type', 'sort', 'level', 'risk_title', 'risk_text', 'risk_level', 'expire_time', 'icon', 'created_by', 'updated_by', 'created_at', 'updated_at'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'type' => 'integer',
        'sort' => 'integer',
        'level' => 'integer',
        'risk_level' => 'integer',
        'expire_time' => 'integer',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'voice_id' => 'integer',
        'icon' => 'string',
    ];

    /**
     * 关联音频（如果存在 file 模块语音表）
     */
    public function voice()
    {
        return $this->belongsTo(RdFileVoice::class, 'voice_id');
    }

    
}